home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.19970929-19971216
/
000085_news@newsmaster….columbia.edu _Mon Oct 13 13:42:19 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
4KB
Return-Path: <news@newsmaster.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id NAA28824
for <kermit.misc@watsun.cc.columbia.edu>; Mon, 13 Oct 1997 13:42:18 -0400 (EDT)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id NAA00594
for kermit.misc@watsun; Mon, 13 Oct 1997 13:42:18 -0400 (EDT)
Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Need script to run automatically after each K95 server-mode file received...
Date: 13 Oct 1997 17:42:13 GMT
Organization: Columbia University
Lines: 68
Message-ID: <61tmhl$j3a$1@apakabar.cc.columbia.edu>
References: <344255EA.40ACF522@southeast.net>
NNTP-Posting-Host: watsun.cc.columbia.edu
Xref: news.columbia.edu comp.protocols.kermit.misc:7861
In article <344255EA.40ACF522@southeast.net>,
newguy <newguy@southeast.net> wrote:
: We run Kermit95 in server-mode to receive files from a database machine
: unattended.
:
: Unfortunately, we need the file names on the received end to be renamed
: from the name that the sending kermit is using. The _real_ name that
: should be used is contained in a text line in the file itself (i.e.
: something like FILENAME=what.name.should.really.be .
:
: Is there a way to get a script to run after each successful receipt of a
: file while remaining in server mode? (A simple script could read the
: file, get the proper name, and then rename the file.)
:
No. As long as Kermit stays in server mode, it won't run any scripts, and
presently we have no provision for "user exits" upon receipt of files, though
this might be added in the future.
: Failing that, could anyone help with a script that would:
: 1) manually wait to receive a file (forever)
: 2) after successful receipt, rename the file
: 3) loop back to step 1
: (In effect, this script would act like server mode)
:
Something like this:
while true {
receive
if fail continue
"rename the file"
}
The question is, how does "rename the file" work? This is left as an
exercise to the reader :-) Here are some hints:
. You can use OPEN READ, READ, and CLOSE read to read lines from
a file. Use this to read the "FILENAME=what.name.should.really.be"
files. To avoid having to do this every time a new file arrives,
read them into an array, then loop through the array to accomplish
the lookup each time.
. Or for the more adventurous, read the file once and create an associative
list in which the variable name is constructed from the left hand side of
the =, and its value is the right hand side. (Subhint: See page 457 of
"Using C-Kermit", 2nd Ed, for how to construct variable names
dynamically).
. Parse the lines from this file using the following functions (examples
assume that \%a holds a line from the file-naming file):
\fstripx(string[,character])
This function removes the rightmost segment of the string that
starts with the given character. Example:
assign original_name \fstripx(\%a,=)
\flop(string[,char])
Removes the leftmost segment of the string that ends with the
given character. If no character is given, period (.) is used.
Example:
assign new_name \flop(\%a,=)
So:
rename \fstripx(\%a,=) \flop(\%a,=)
- Frank